import {
	INCREMENT,
	DECREMENT,
	SRC,
	SRC2,
	SRC3,
	THEMECHANGE,
	REMEMBERUSER,
	NAVLIST
} from './types'
import getters from './getters'
import defaultDark from '../assets/img/theme_default_head.jpg'
import defaultDark2 from '../assets/img/theme_default_head2.jpg'
const state = {
	count: 20,
	src: SRC,
	src2: SRC2,
	src3: SRC3,
	isLogin: false,
	setuser: {},
	permissions: {},
	projectid: '',
	pageid: '',
	theme: ["#2eb398","#27977f",defaultDark,defaultDark2,"dark","#324157","#bfcbd9"]
};

const mutations = {
	[NAVLIST](state,value) {
		state.permissions = value;
		localStorage.setItem("ZULONGBINAVLIST",JSON.stringify(value));
		for(var i in value){
			state.projectid = i.split('-')[1];
			localStorage.setItem("ZULONGBIPROJECTID",i.split('-')[1])
			localStorage.setItem("ZULONGBISORTID", i.split('-')[0])
			for(var j in value[i]){
				state.pageid = value[i][j][0];
				localStorage.setItem("ZULONGBIPAGEID",value[i][j][0])
				break;
			}
			break;
		}
	},
	[REMEMBERUSER](state,value) {
		state.setuser = value;
		state.isLogin = true;
		localStorage.setItem("ZULONGBIISLOGING",true);
	},
	[THEMECHANGE](state,value) {
		state.theme = value;
	},
	[INCREMENT](state) {
		state.count++;
	},
	[DECREMENT](state) {
		state.count--;
	}
};

export default {
	state,
	mutations,
	getters
}